package concurrent;

import java.util.Random;

public class MyThreadLocalExample {
    private static ThreadLocal<Integer> local = ThreadLocal.withInitial(() -> 0);

    public static void main(String[] args) {
        Runnable task = () -> {
            local.set((int) Thread.currentThread().getId());
            System.out.println(Thread.currentThread().getName() + ": " + local.get());
        };

        Thread t1 = new Thread(task);
        Thread t2 = new Thread(task);
        t1.start();
        t2.start();
    }
}